﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using PlaygroundSplines;
using UnityEngine;

namespace ParticlePlayground
{
	// Token: 0x0200015B RID: 347
	[ExecuteInEditMode]
	public class PlaygroundC : MonoBehaviour
	{
		// Token: 0x1400000F RID: 15
		// (add) Token: 0x0600078E RID: 1934 RVA: 0x0002CD1C File Offset: 0x0002AF1C
		// (remove) Token: 0x0600078F RID: 1935 RVA: 0x0002CD34 File Offset: 0x0002AF34
		public static event OnPlaygroundParticle particleEventBirth;

		// Token: 0x14000010 RID: 16
		// (add) Token: 0x06000790 RID: 1936 RVA: 0x0002CD4C File Offset: 0x0002AF4C
		// (remove) Token: 0x06000791 RID: 1937 RVA: 0x0002CD64 File Offset: 0x0002AF64
		public static event OnPlaygroundParticle particleEventDeath;

		// Token: 0x14000011 RID: 17
		// (add) Token: 0x06000792 RID: 1938 RVA: 0x0002CD7C File Offset: 0x0002AF7C
		// (remove) Token: 0x06000793 RID: 1939 RVA: 0x0002CD94 File Offset: 0x0002AF94
		public static event OnPlaygroundParticle particleEventCollision;

		// Token: 0x14000012 RID: 18
		// (add) Token: 0x06000794 RID: 1940 RVA: 0x0002CDAC File Offset: 0x0002AFAC
		// (remove) Token: 0x06000795 RID: 1941 RVA: 0x0002CDC4 File Offset: 0x0002AFC4
		public static event OnPlaygroundParticle particleEventTime;

		// Token: 0x06000796 RID: 1942 RVA: 0x0002CDDC File Offset: 0x0002AFDC
		public static void SendParticleEventBirth(PlaygroundEventParticle eventParticle)
		{
			if (PlaygroundC.particleEventBirthInitialized)
			{
				PlaygroundC.particleEventBirth(eventParticle);
			}
		}

		// Token: 0x06000797 RID: 1943 RVA: 0x0002CDF4 File Offset: 0x0002AFF4
		public static void SendParticleEventDeath(PlaygroundEventParticle eventParticle)
		{
			if (PlaygroundC.particleEventDeathInitialized)
			{
				PlaygroundC.particleEventDeath(eventParticle);
			}
		}

		// Token: 0x06000798 RID: 1944 RVA: 0x0002CE0C File Offset: 0x0002B00C
		public static void SendParticleEventCollision(PlaygroundEventParticle eventParticle)
		{
			if (PlaygroundC.particleEventCollisionInitialized)
			{
				PlaygroundC.particleEventCollision(eventParticle);
			}
		}

		// Token: 0x06000799 RID: 1945 RVA: 0x0002CE24 File Offset: 0x0002B024
		public static void SendParticleEventTime(PlaygroundEventParticle eventParticle)
		{
			if (PlaygroundC.particleEventTimeInitialized)
			{
				PlaygroundC.particleEventTime(eventParticle);
			}
		}

		// Token: 0x0600079A RID: 1946 RVA: 0x0002CE3C File Offset: 0x0002B03C
		public static PlaygroundParticlesC Particle()
		{
			return PlaygroundC.ResourceInstantiate("Particle Playground System").GetComponent<PlaygroundParticlesC>();
		}

		// Token: 0x0600079B RID: 1947 RVA: 0x0002CE5C File Offset: 0x0002B05C
		public static PlaygroundParticlesC ParticleNew()
		{
			PlaygroundParticlesC playgroundParticlesC = PlaygroundParticlesC.CreateParticleObject("Particle Playground System " + PlaygroundC.particlesQuantity, Vector3.zero, Quaternion.identity, 1f, new Material(Shader.Find("Playground/Vertex Color")));
			playgroundParticlesC.particleCache = new ParticleSystem.Particle[playgroundParticlesC.particleCount];
			PlaygroundParticlesC.OnCreatePlaygroundParticles(playgroundParticlesC);
			return playgroundParticlesC;
		}

		// Token: 0x0600079C RID: 1948 RVA: 0x0002CEBC File Offset: 0x0002B0BC
		public static PlaygroundParticlesC Particle(Texture2D image, string name, Vector3 position, Quaternion rotation, Vector3 offset, float particleSize, float scale, Material material)
		{
			return PlaygroundParticlesC.CreatePlaygroundParticles(new Texture2D[]
			{
				image
			}, name, position, rotation, offset, particleSize, scale, material);
		}

		// Token: 0x0600079D RID: 1949 RVA: 0x0002CED8 File Offset: 0x0002B0D8
		public static PlaygroundParticlesC Particle(Texture2D image)
		{
			return PlaygroundParticlesC.CreatePlaygroundParticles(new Texture2D[]
			{
				image
			}, "Particle Playground System " + PlaygroundC.particlesQuantity, Vector3.zero, Quaternion.identity, Vector3.zero, 1f, 1f, new Material(Shader.Find("Playground/Vertex Color")));
		}

		// Token: 0x0600079E RID: 1950 RVA: 0x0002CF30 File Offset: 0x0002B130
		public static PlaygroundParticlesC Particle(Texture2D[] images, string name, Vector3 position, Quaternion rotation, Vector3 offset, float particleSize, float scale, Material material)
		{
			return PlaygroundParticlesC.CreatePlaygroundParticles(images, name, position, rotation, offset, particleSize, scale, material);
		}

		// Token: 0x0600079F RID: 1951 RVA: 0x0002CF44 File Offset: 0x0002B144
		public static PlaygroundParticlesC Particle(Texture2D[] images)
		{
			return PlaygroundParticlesC.CreatePlaygroundParticles(images, "Particle Playground System " + PlaygroundC.particlesQuantity, Vector3.zero, Quaternion.identity, Vector3.zero, 1f, 1f, new Material(Shader.Find("Playground/Vertex Color")));
		}

		// Token: 0x060007A0 RID: 1952 RVA: 0x0002CF94 File Offset: 0x0002B194
		public static PlaygroundParticlesC Particle(Mesh mesh, Texture2D texture, string name, Vector3 position, Quaternion rotation, float particleScale, Vector3 offset, Material material)
		{
			return MeshParticles.CreateMeshParticles(new Mesh[]
			{
				mesh
			}, new Texture2D[]
			{
				texture
			}, null, name, position, rotation, particleScale, new Vector3[]
			{
				offset
			}, material);
		}

		// Token: 0x060007A1 RID: 1953 RVA: 0x0002CFD8 File Offset: 0x0002B1D8
		public static PlaygroundParticlesC Particle(Mesh mesh, Texture2D texture)
		{
			return MeshParticles.CreateMeshParticles(new Mesh[]
			{
				mesh
			}, new Texture2D[]
			{
				texture
			}, null, "Particle Playground System " + PlaygroundC.particlesQuantity, Vector3.zero, Quaternion.identity, 1f, new Vector3[]
			{
				Vector3.zero
			}, new Material(Shader.Find("Playground/Vertex Color")));
		}

		// Token: 0x060007A2 RID: 1954 RVA: 0x0002D048 File Offset: 0x0002B248
		public static PlaygroundParticlesC Particle(Mesh[] meshes, Texture2D[] textures, string name, Vector3 position, Quaternion rotation, float particleScale, Vector3[] offsets, Material material)
		{
			return MeshParticles.CreateMeshParticles(meshes, textures, null, name, position, rotation, particleScale, offsets, material);
		}

		// Token: 0x060007A3 RID: 1955 RVA: 0x0002D068 File Offset: 0x0002B268
		public static PlaygroundParticlesC Particle(Mesh[] meshes, Texture2D[] textures)
		{
			return MeshParticles.CreateMeshParticles(meshes, textures, null, "Particle Playground System " + PlaygroundC.particlesQuantity, Vector3.zero, Quaternion.identity, 1f, new Vector3[meshes.Length], new Material(Shader.Find("Playground/Vertex Color")));
		}

		// Token: 0x060007A4 RID: 1956 RVA: 0x0002D0B8 File Offset: 0x0002B2B8
		public static int Emit(PlaygroundParticlesC playgroundParticles)
		{
			return playgroundParticles.Emit(playgroundParticles.scriptedEmissionPosition, playgroundParticles.scriptedEmissionVelocity, playgroundParticles.scriptedEmissionColor);
		}

		// Token: 0x060007A5 RID: 1957 RVA: 0x0002D0D8 File Offset: 0x0002B2D8
		public static int Emit(PlaygroundParticlesC playgroundParticles, Vector3 position, Vector3 normal, Color color)
		{
			return playgroundParticles.Emit(position, normal, color);
		}

		// Token: 0x060007A6 RID: 1958 RVA: 0x0002D0E8 File Offset: 0x0002B2E8
		public static void Emit(PlaygroundParticlesC playgroundParticles, bool setEmission)
		{
			playgroundParticles.Emit(setEmission);
		}

		// Token: 0x060007A7 RID: 1959 RVA: 0x0002D0F4 File Offset: 0x0002B2F4
		public static void GetPosition(SkinnedWorldObject particleStateWorldObject, bool updateNormals)
		{
			PlaygroundParticlesC.GetPosition(particleStateWorldObject, updateNormals);
		}

		// Token: 0x060007A8 RID: 1960 RVA: 0x0002D100 File Offset: 0x0002B300
		public static void GetPosition(Vector3[] vertices, WorldObject particleStateWorldObject)
		{
			PlaygroundParticlesC.GetPosition(vertices, particleStateWorldObject);
		}

		// Token: 0x060007A9 RID: 1961 RVA: 0x0002D10C File Offset: 0x0002B30C
		public static void GetNormals(Vector3[] normals, WorldObject particleStateWorldObject)
		{
			PlaygroundParticlesC.GetNormals(normals, particleStateWorldObject);
		}

		// Token: 0x060007AA RID: 1962 RVA: 0x0002D118 File Offset: 0x0002B318
		public static void SetAlpha(PlaygroundParticlesC playgroundParticles, float alpha)
		{
			PlaygroundParticlesC.SetAlpha(playgroundParticles, alpha);
		}

		// Token: 0x060007AB RID: 1963 RVA: 0x0002D124 File Offset: 0x0002B324
		public static void SetSize(PlaygroundParticlesC playgroundParticles, float size)
		{
			PlaygroundParticlesC.SetSize(playgroundParticles, size);
		}

		// Token: 0x060007AC RID: 1964 RVA: 0x0002D130 File Offset: 0x0002B330
		public static void Translate(PlaygroundParticlesC playgroundParticles, Vector3 direction)
		{
			PlaygroundParticlesC.Translate(playgroundParticles, direction);
		}

		// Token: 0x060007AD RID: 1965 RVA: 0x0002D13C File Offset: 0x0002B33C
		public static void Add(PlaygroundParticlesC playgroundParticles, ParticleStateC state)
		{
			PlaygroundParticlesC.Add(playgroundParticles, state);
		}

		// Token: 0x060007AE RID: 1966 RVA: 0x0002D148 File Offset: 0x0002B348
		public static void Add(PlaygroundParticlesC playgroundParticles, Texture2D image, float scale, Vector3 offset, string stateName)
		{
			PlaygroundParticlesC.Add(playgroundParticles, image, scale, offset, stateName, null);
		}

		// Token: 0x060007AF RID: 1967 RVA: 0x0002D158 File Offset: 0x0002B358
		public static void Add(PlaygroundParticlesC playgroundParticles, Texture2D image, float scale, Vector3 offset, string stateName, Transform stateTransform)
		{
			PlaygroundParticlesC.Add(playgroundParticles, image, scale, offset, stateName, stateTransform);
		}

		// Token: 0x060007B0 RID: 1968 RVA: 0x0002D168 File Offset: 0x0002B368
		public static void Add(PlaygroundParticlesC playgroundParticles, Texture2D image, Texture2D depthmap, float depthmapStrength, float scale, Vector3 offset, string stateName)
		{
			PlaygroundParticlesC.Add(playgroundParticles, image, depthmap, depthmapStrength, scale, offset, stateName, null);
		}

		// Token: 0x060007B1 RID: 1969 RVA: 0x0002D17C File Offset: 0x0002B37C
		public static void Add(PlaygroundParticlesC playgroundParticles, Texture2D image, Texture2D depthmap, float depthmapStrength, float scale, Vector3 offset, string stateName, Transform stateTransform)
		{
			PlaygroundParticlesC.Add(playgroundParticles, image, depthmap, depthmapStrength, scale, offset, stateName, stateTransform);
		}

		// Token: 0x060007B2 RID: 1970 RVA: 0x0002D190 File Offset: 0x0002B390
		public static void Add(PlaygroundParticlesC playgroundParticles, Mesh mesh, float scale, Vector3 offset, string stateName)
		{
			MeshParticles.Add(playgroundParticles, mesh, scale, offset, stateName, null);
		}

		// Token: 0x060007B3 RID: 1971 RVA: 0x0002D1A0 File Offset: 0x0002B3A0
		public static void Add(PlaygroundParticlesC playgroundParticles, Mesh mesh, float scale, Vector3 offset, string stateName, Transform stateTransform)
		{
			MeshParticles.Add(playgroundParticles, mesh, scale, offset, stateName, stateTransform);
		}

		// Token: 0x060007B4 RID: 1972 RVA: 0x0002D1B0 File Offset: 0x0002B3B0
		public static void Add(PlaygroundParticlesC playgroundParticles, Mesh mesh, Texture2D texture, float scale, Vector3 offset, string stateName)
		{
			MeshParticles.Add(playgroundParticles, mesh, texture, scale, offset, stateName, null);
		}

		// Token: 0x060007B5 RID: 1973 RVA: 0x0002D1C0 File Offset: 0x0002B3C0
		public static void Add(PlaygroundParticlesC playgroundParticles, Mesh mesh, Texture2D texture, float scale, Vector3 offset, string stateName, Transform stateTransform)
		{
			MeshParticles.Add(playgroundParticles, mesh, texture, scale, offset, stateName, stateTransform);
		}

		// Token: 0x060007B6 RID: 1974 RVA: 0x0002D1D4 File Offset: 0x0002B3D4
		public static PlaygroundColliderC AddCollider(PlaygroundParticlesC playgroundParticles)
		{
			PlaygroundColliderC playgroundColliderC = new PlaygroundColliderC();
			playgroundParticles.colliders.Add(playgroundColliderC);
			return playgroundColliderC;
		}

		// Token: 0x060007B7 RID: 1975 RVA: 0x0002D1F4 File Offset: 0x0002B3F4
		public static PlaygroundColliderC AddCollider(PlaygroundParticlesC playgroundParticles, Transform transform)
		{
			PlaygroundColliderC playgroundColliderC = new PlaygroundColliderC();
			playgroundColliderC.transform = transform;
			playgroundParticles.colliders.Add(playgroundColliderC);
			return playgroundColliderC;
		}

		// Token: 0x060007B8 RID: 1976 RVA: 0x0002D21C File Offset: 0x0002B41C
		public static void SetParticleCount(PlaygroundParticlesC playgroundParticles, int amount)
		{
			PlaygroundParticlesC.SetParticleCount(playgroundParticles, amount);
		}

		// Token: 0x060007B9 RID: 1977 RVA: 0x0002D228 File Offset: 0x0002B428
		public static void SetLifetime(PlaygroundParticlesC playgroundParticles, float time)
		{
			PlaygroundParticlesC.SetLifetime(playgroundParticles, playgroundParticles.sorting, time);
		}

		// Token: 0x060007BA RID: 1978 RVA: 0x0002D238 File Offset: 0x0002B438
		public static void SetMaterial(PlaygroundParticlesC playgroundParticles, Material particleMaterial)
		{
			PlaygroundParticlesC.SetMaterial(playgroundParticles, particleMaterial);
		}

		// Token: 0x060007BB RID: 1979 RVA: 0x0002D244 File Offset: 0x0002B444
		public static void Destroy(PlaygroundParticlesC playgroundParticles)
		{
			PlaygroundParticlesC.Destroy(playgroundParticles);
		}

		// Token: 0x060007BC RID: 1980 RVA: 0x0002D24C File Offset: 0x0002B44C
		public static WorldObject WorldObject(Transform meshTransform)
		{
			return PlaygroundParticlesC.NewWorldObject(meshTransform);
		}

		// Token: 0x060007BD RID: 1981 RVA: 0x0002D254 File Offset: 0x0002B454
		public static SkinnedWorldObject SkinnedWorldObject(Transform meshTransform)
		{
			return PlaygroundParticlesC.NewSkinnedWorldObject(meshTransform);
		}

		// Token: 0x060007BE RID: 1982 RVA: 0x0002D25C File Offset: 0x0002B45C
		public static ManipulatorObjectC ManipulatorObject(MANIPULATORTYPEC type, LayerMask affects, Transform manipulatorTransform, float size, float strength)
		{
			return PlaygroundParticlesC.NewManipulatorObject(type, affects, manipulatorTransform, size, strength, null);
		}

		// Token: 0x060007BF RID: 1983 RVA: 0x0002D26C File Offset: 0x0002B46C
		public static ManipulatorObjectC ManipulatorObject(Transform manipulatorTransform)
		{
			LayerMask affects = -1;
			return PlaygroundParticlesC.NewManipulatorObject(MANIPULATORTYPEC.Attractor, affects, manipulatorTransform, 1f, 1f, null);
		}

		// Token: 0x060007C0 RID: 1984 RVA: 0x0002D294 File Offset: 0x0002B494
		public static ManipulatorObjectC ManipulatorObject(MANIPULATORTYPEC type, LayerMask affects, Transform manipulatorTransform, float size, float strength, PlaygroundParticlesC playgroundParticles)
		{
			return PlaygroundParticlesC.NewManipulatorObject(type, affects, manipulatorTransform, size, strength, playgroundParticles);
		}

		// Token: 0x060007C1 RID: 1985 RVA: 0x0002D2A4 File Offset: 0x0002B4A4
		public static ManipulatorObjectC ManipulatorObject(Transform manipulatorTransform, PlaygroundParticlesC playgroundParticles)
		{
			LayerMask affects = -1;
			return PlaygroundParticlesC.NewManipulatorObject(MANIPULATORTYPEC.Attractor, affects, manipulatorTransform, 1f, 1f, playgroundParticles);
		}

		// Token: 0x060007C2 RID: 1986 RVA: 0x0002D2CC File Offset: 0x0002B4CC
		public static ManipulatorObjectC GetManipulator(int i)
		{
			if (PlaygroundC.reference.manipulators.Count > 0 && PlaygroundC.reference.manipulators[i % PlaygroundC.reference.manipulators.Count] != null)
			{
				return PlaygroundC.reference.manipulators[i % PlaygroundC.reference.manipulators.Count];
			}
			return null;
		}

		// Token: 0x060007C3 RID: 1987 RVA: 0x0002D338 File Offset: 0x0002B538
		public static ManipulatorObjectC GetManipulator(int i, PlaygroundParticlesC playgroundParticles)
		{
			if (playgroundParticles.manipulators.Count > 0 && playgroundParticles.manipulators[i % playgroundParticles.manipulators.Count] != null)
			{
				return playgroundParticles.manipulators[i % playgroundParticles.manipulators.Count];
			}
			return null;
		}

		// Token: 0x060007C4 RID: 1988 RVA: 0x0002D390 File Offset: 0x0002B590
		public static List<PlaygroundEventParticle> GetManipulatorParticles(int manipulator, PlaygroundParticlesC playgroundParticles)
		{
			if (manipulator < 0 || manipulator >= playgroundParticles.manipulators.Count)
			{
				return null;
			}
			List<PlaygroundEventParticle> list = new List<PlaygroundEventParticle>();
			PlaygroundEventParticle playgroundEventParticle = new PlaygroundEventParticle();
			for (int i = 0; i < playgroundParticles.particleCount; i++)
			{
				if (playgroundParticles.manipulators[manipulator].Contains(playgroundParticles.playgroundCache.position[i], playgroundParticles.manipulators[manipulator].transform.position))
				{
					playgroundParticles.UpdateEventParticle(playgroundEventParticle, i);
					list.Add(playgroundEventParticle.Clone());
				}
			}
			return list;
		}

		// Token: 0x060007C5 RID: 1989 RVA: 0x0002D434 File Offset: 0x0002B634
		public static List<PlaygroundEventParticle> GetManipulatorParticles(int manipulator)
		{
			if (manipulator < 0 || manipulator >= PlaygroundC.reference.manipulators.Count)
			{
				return null;
			}
			List<PlaygroundEventParticle> list = new List<PlaygroundEventParticle>();
			PlaygroundEventParticle playgroundEventParticle = new PlaygroundEventParticle();
			for (int i = 0; i < PlaygroundC.reference.particleSystems.Count; i++)
			{
				for (int j = 0; j < PlaygroundC.reference.particleSystems[i].particleCount; j++)
				{
					if (PlaygroundC.reference.particleSystems[i].manipulators[manipulator].Contains(PlaygroundC.reference.particleSystems[i].playgroundCache.position[j], PlaygroundC.reference.particleSystems[i].manipulators[manipulator].transform.position))
					{
						PlaygroundC.reference.particleSystems[i].UpdateEventParticle(playgroundEventParticle, j);
						list.Add(playgroundEventParticle.Clone());
					}
				}
			}
			return list;
		}

		// Token: 0x060007C6 RID: 1990 RVA: 0x0002D548 File Offset: 0x0002B748
		public static Transform CreateTransform()
		{
			return new GameObject("Source Transform").transform;
		}

		// Token: 0x060007C7 RID: 1991 RVA: 0x0002D55C File Offset: 0x0002B75C
		public static Transform CreatePlaygroundTransform(PlaygroundParticlesC playgroundParticles)
		{
			Transform transform = PlaygroundC.CreateTransform();
			PlaygroundTransformC playgroundTransformC = new PlaygroundTransformC();
			playgroundTransformC.transform = transform;
			if (playgroundParticles.sourceTransforms.Count == 1 && playgroundParticles.sourceTransforms[0].transform == null)
			{
				playgroundParticles.sourceTransforms[0].transform = transform;
			}
			else
			{
				playgroundParticles.sourceTransforms.Add(playgroundTransformC);
			}
			transform.parent = playgroundParticles.particleSystemTransform;
			transform.localPosition = Vector3.zero;
			Transform transform2 = transform;
			transform2.name = transform2.name + " " + playgroundParticles.sourceTransforms.Count.ToString();
			return transform;
		}

		// Token: 0x060007C8 RID: 1992 RVA: 0x0002D610 File Offset: 0x0002B810
		public static PlaygroundSplines.PlaygroundSpline CreateSpline()
		{
			GameObject gameObject = new GameObject("Playground Spline", new Type[]
			{
				typeof(PlaygroundSplines.PlaygroundSpline)
			});
			return (PlaygroundSplines.PlaygroundSpline)gameObject.GetComponent(typeof(PlaygroundSplines.PlaygroundSpline));
		}

		// Token: 0x060007C9 RID: 1993 RVA: 0x0002D650 File Offset: 0x0002B850
		public static PlaygroundSplines.PlaygroundSpline CreateSpline(PlaygroundParticlesC playgroundParticles)
		{
			PlaygroundSplines.PlaygroundSpline playgroundSpline = PlaygroundC.CreateSpline();
			playgroundSpline.Reset();
			if (playgroundParticles.splines.Count == 1 && playgroundParticles.splines[0] == null)
			{
				playgroundParticles.splines[0] = playgroundSpline;
			}
			else
			{
				playgroundParticles.splines.Add(playgroundSpline);
			}
			playgroundSpline.transform.parent = playgroundParticles.particleSystemTransform;
			playgroundSpline.transform.localPosition = Vector3.zero;
			PlaygroundSplines.PlaygroundSpline playgroundSpline2 = playgroundSpline;
			playgroundSpline2.name = playgroundSpline2.name + " " + playgroundParticles.splines.Count.ToString();
			playgroundSpline.AddUser(playgroundParticles.particleSystemTransform);
			return playgroundSpline;
		}

		// Token: 0x060007CA RID: 1994 RVA: 0x0002D708 File Offset: 0x0002B908
		public static PlaygroundSplines.PlaygroundSpline CreateSpline(ManipulatorPropertyC manipulatorProperty)
		{
			PlaygroundSplines.PlaygroundSpline playgroundSpline = PlaygroundC.CreateSpline();
			playgroundSpline.Reset();
			manipulatorProperty.splineTarget = playgroundSpline;
			return playgroundSpline;
		}

		// Token: 0x060007CB RID: 1995 RVA: 0x0002D72C File Offset: 0x0002B92C
		public static PlaygroundEventC CreateEvent()
		{
			return new PlaygroundEventC();
		}

		// Token: 0x060007CC RID: 1996 RVA: 0x0002D734 File Offset: 0x0002B934
		public static PlaygroundEventC CreateEvent(PlaygroundParticlesC playgroundParticles)
		{
			if (playgroundParticles == null)
			{
				return null;
			}
			if (playgroundParticles.events == null)
			{
				playgroundParticles.events = new List<PlaygroundEventC>();
			}
			playgroundParticles.events.Add(new PlaygroundEventC());
			return playgroundParticles.events[playgroundParticles.events.Count - 1];
		}

		// Token: 0x060007CD RID: 1997 RVA: 0x0002D790 File Offset: 0x0002B990
		public static PlaygroundEventC GetEvent(int i, PlaygroundParticlesC playgroundParticles)
		{
			if (playgroundParticles.events.Count > 0 && playgroundParticles.events[i % playgroundParticles.events.Count] != null)
			{
				return playgroundParticles.events[i % playgroundParticles.events.Count];
			}
			return null;
		}

		// Token: 0x060007CE RID: 1998 RVA: 0x0002D7E8 File Offset: 0x0002B9E8
		public static void RemoveEvent(int i, PlaygroundParticlesC playgroundParticles)
		{
			i %= playgroundParticles.events.Count;
			if (playgroundParticles.events.Count > 0 && playgroundParticles.events[i] != null)
			{
				if (playgroundParticles.events[i].target != null)
				{
					for (int j = 0; j < playgroundParticles.events[i].target.eventControlledBy.Count; j++)
					{
						if (playgroundParticles.events[i].target.eventControlledBy[j] == playgroundParticles)
						{
							playgroundParticles.events[i].target.eventControlledBy.RemoveAt(j);
						}
					}
				}
				playgroundParticles.events.RemoveAt(i);
			}
		}

		// Token: 0x060007CF RID: 1999 RVA: 0x0002D8C0 File Offset: 0x0002BAC0
		public static PlaygroundParticlesC GetParticles(int i)
		{
			if (PlaygroundC.reference.particleSystems.Count > 0 && PlaygroundC.reference.particleSystems[i % PlaygroundC.reference.particleSystems.Count] != null)
			{
				return PlaygroundC.reference.particleSystems[i % PlaygroundC.reference.particleSystems.Count];
			}
			return null;
		}

		// Token: 0x060007D0 RID: 2000 RVA: 0x0002D930 File Offset: 0x0002BB30
		public static ParticleProjectionC ParticleProjection(PlaygroundParticlesC playgroundParticles)
		{
			return PlaygroundParticlesC.NewProjectionObject(playgroundParticles);
		}

		// Token: 0x060007D1 RID: 2001 RVA: 0x0002D938 File Offset: 0x0002BB38
		public static PaintObjectC PaintObject(PlaygroundParticlesC playgroundParticles)
		{
			return PlaygroundParticlesC.NewPaintObject(playgroundParticles);
		}

		// Token: 0x060007D2 RID: 2002 RVA: 0x0002D940 File Offset: 0x0002BB40
		public static int Paint(PlaygroundParticlesC playgroundParticles, Vector3 position, Vector3 normal, Transform parent, Color32 color)
		{
			return playgroundParticles.paint.Paint(position, normal, parent, color);
		}

		// Token: 0x060007D3 RID: 2003 RVA: 0x0002D954 File Offset: 0x0002BB54
		public static void Paint(PaintObjectC paintObject, Vector3 position, Vector3 normal, Transform parent, Color32 color)
		{
			paintObject.Paint(position, normal, parent, color);
		}

		// Token: 0x060007D4 RID: 2004 RVA: 0x0002D964 File Offset: 0x0002BB64
		public static bool Erase(PlaygroundParticlesC playgroundParticles, Vector3 position, float radius)
		{
			return playgroundParticles.paint.Erase(position, radius);
		}

		// Token: 0x060007D5 RID: 2005 RVA: 0x0002D974 File Offset: 0x0002BB74
		public static bool Erase(PaintObjectC paintObject, Vector3 position, float radius)
		{
			return paintObject.Erase(position, radius);
		}

		// Token: 0x060007D6 RID: 2006 RVA: 0x0002D980 File Offset: 0x0002BB80
		public static bool Erase(PlaygroundParticlesC playgroundParticles, int index)
		{
			return playgroundParticles.paint.Erase(index);
		}

		// Token: 0x060007D7 RID: 2007 RVA: 0x0002D990 File Offset: 0x0002BB90
		public static void ClearPaint(PlaygroundParticlesC playgroundParticles)
		{
			if (playgroundParticles.paint != null)
			{
				playgroundParticles.paint.ClearPaint();
			}
		}

		// Token: 0x060007D8 RID: 2008 RVA: 0x0002D9A8 File Offset: 0x0002BBA8
		public static int GetPaintPositionLength(PlaygroundParticlesC playgroundParticles)
		{
			return playgroundParticles.paint.positionLength;
		}

		// Token: 0x060007D9 RID: 2009 RVA: 0x0002D9B8 File Offset: 0x0002BBB8
		public static void SetInitialTargetPosition(PlaygroundParticlesC playgroundParticles, Vector3 position)
		{
			PlaygroundParticlesC.SetInitialTargetPosition(playgroundParticles, position, true);
		}

		// Token: 0x060007DA RID: 2010 RVA: 0x0002D9C4 File Offset: 0x0002BBC4
		public static void Emission(PlaygroundParticlesC playgroundParticles, bool emit)
		{
			PlaygroundParticlesC.Emission(playgroundParticles, emit, false);
		}

		// Token: 0x060007DB RID: 2011 RVA: 0x0002D9D0 File Offset: 0x0002BBD0
		public static void Emission(PlaygroundParticlesC playgroundParticles, bool emit, bool restEmission)
		{
			PlaygroundParticlesC.Emission(playgroundParticles, emit, restEmission);
		}

		// Token: 0x060007DC RID: 2012 RVA: 0x0002D9DC File Offset: 0x0002BBDC
		public static void Clear(PlaygroundParticlesC playgroundParticles)
		{
			PlaygroundParticlesC.Clear(playgroundParticles);
		}

		// Token: 0x060007DD RID: 2013 RVA: 0x0002D9E4 File Offset: 0x0002BBE4
		public static void RefreshScatter(PlaygroundParticlesC playgroundParticles)
		{
			playgroundParticles.RefreshScatter();
		}

		// Token: 0x060007DE RID: 2014 RVA: 0x0002D9EC File Offset: 0x0002BBEC
		public static PlaygroundParticlesC InstantiatePreset(string presetName)
		{
			GameObject gameObject = PlaygroundC.ResourceInstantiate("Presets/" + presetName);
			PlaygroundParticlesC component = gameObject.GetComponent<PlaygroundParticlesC>();
			if (component != null)
			{
				if (PlaygroundC.reference == null)
				{
					PlaygroundC.reference = PlaygroundC.ResourceInstantiate("Playground Manager").GetComponent<PlaygroundC>();
				}
				if (PlaygroundC.reference)
				{
					if (PlaygroundC.reference.autoGroup && component.particleSystemTransform.parent == null)
					{
						component.particleSystemTransform.parent = PlaygroundC.referenceTransform;
					}
					PlaygroundC.particlesQuantity++;
					component.particleSystemId = PlaygroundC.particlesQuantity - 1;
				}
				gameObject.name = presetName;
				return component;
			}
			if (gameObject.name.Contains("Presets/"))
			{
				gameObject.name = gameObject.name.Remove(0, 8);
			}
			return null;
		}

		// Token: 0x060007DF RID: 2015 RVA: 0x0002DAD0 File Offset: 0x0002BCD0
		public static PlaygroundParticlesC InstantiatePreset(string categoryName, string presetName)
		{
			return PlaygroundC.InstantiatePreset(categoryName + "/" + presetName);
		}

		// Token: 0x060007E0 RID: 2016 RVA: 0x0002DAE4 File Offset: 0x0002BCE4
		public static bool HasReference()
		{
			return PlaygroundC.hasReference;
		}

		// Token: 0x060007E1 RID: 2017 RVA: 0x0002DAEC File Offset: 0x0002BCEC
		public static bool HasPlaygroundPool()
		{
			return PlaygroundC.hasPlaygroundPool;
		}

		// Token: 0x060007E2 RID: 2018 RVA: 0x0002DAF4 File Offset: 0x0002BCF4
		public virtual bool IsDoneThread()
		{
			return this.isDoneThread;
		}

		// Token: 0x060007E3 RID: 2019 RVA: 0x0002DAFC File Offset: 0x0002BCFC
		public virtual bool IsDoneThreadTurbulence()
		{
			return this.isDoneThreadTurbulence;
		}

		// Token: 0x060007E4 RID: 2020 RVA: 0x0002DB04 File Offset: 0x0002BD04
		public virtual bool IsDoneThreadSkinnedMeshes()
		{
			return this.isDoneThreadSkinned;
		}

		// Token: 0x060007E5 RID: 2021 RVA: 0x0002DB0C File Offset: 0x0002BD0C
		public virtual bool IsFirstUnsafeAutomaticFrames()
		{
			return this.isFirstUnsafeAutomaticFrames;
		}

		// Token: 0x060007E6 RID: 2022 RVA: 0x0002DB14 File Offset: 0x0002BD14
		public virtual bool HasEnabledGlobalManipulators()
		{
			if (this.manipulators.Count > 0)
			{
				for (int i = 0; i < this.manipulators.Count; i++)
				{
					if (this.manipulators[i].enabled && this.manipulators[i].transform != null && this.manipulators[i].transform.transform != null)
					{
						return true;
					}
				}
			}
			return false;
		}

		// Token: 0x060007E7 RID: 2023 RVA: 0x0002DBA0 File Offset: 0x0002BDA0
		public static Color32[] GetPixels(Texture2D image)
		{
			if (image == null)
			{
				return null;
			}
			if (PlaygroundC.reference && PlaygroundC.reference.pixelFilterMode == PIXELMODEC.Bilinear)
			{
				Color32[] array = new Color32[image.width * image.height];
				for (int i = 0; i < image.height; i++)
				{
					for (int j = 0; j < image.width; j++)
					{
						array[i * image.width + j] = image.GetPixelBilinear((float)j * 1f / (float)image.width, (float)i * 1f / (float)image.height);
					}
				}
				return array;
			}
			return image.GetPixels32();
		}

		// Token: 0x060007E8 RID: 2024 RVA: 0x0002DC64 File Offset: 0x0002BE64
		public static Vector3 Offset(PLAYGROUNDORIGINC origin, int imageWidth, int imageHeight, float meshScale)
		{
			Vector3 zero = Vector3.zero;
			switch (origin)
			{
			case PLAYGROUNDORIGINC.TopLeft:
				zero.y = (float)(-(float)imageHeight) * meshScale;
				break;
			case PLAYGROUNDORIGINC.TopCenter:
				zero.y = (float)(-(float)imageHeight) * meshScale;
				zero.x = (float)(-(float)imageWidth) * meshScale / 2f;
				break;
			case PLAYGROUNDORIGINC.TopRight:
				zero.y = (float)(-(float)imageHeight) * meshScale;
				zero.x = (float)(-(float)imageWidth) * meshScale;
				break;
			case PLAYGROUNDORIGINC.MiddleLeft:
				zero.y = (float)(-(float)imageHeight) * meshScale / 2f;
				break;
			case PLAYGROUNDORIGINC.MiddleCenter:
				zero.y = (float)(-(float)imageHeight) * meshScale / 2f;
				zero.x = (float)(-(float)imageWidth) * meshScale / 2f;
				break;
			case PLAYGROUNDORIGINC.MiddleRight:
				zero.y = (float)(-(float)imageHeight) * meshScale / 2f;
				zero.x = (float)(-(float)imageWidth) * meshScale;
				break;
			case PLAYGROUNDORIGINC.BottomCenter:
				zero.x = (float)(-(float)imageWidth) * meshScale / 2f;
				break;
			case PLAYGROUNDORIGINC.BottomRight:
				zero.x = (float)(-(float)imageWidth) * meshScale;
				break;
			}
			return zero;
		}

		// Token: 0x060007E9 RID: 2025 RVA: 0x0002DD88 File Offset: 0x0002BF88
		public static Vector3[] RandomVector3(int length, Vector3 min, Vector3 max)
		{
			Vector3[] array = new Vector3[length];
			for (int i = 0; i < length; i++)
			{
				array[i] = new Vector3(PlaygroundParticlesC.RandomRange(PlaygroundC.random, min.x, max.x), PlaygroundParticlesC.RandomRange(PlaygroundC.random, min.y, max.y), PlaygroundParticlesC.RandomRange(PlaygroundC.random, min.z, max.z));
			}
			return array;
		}

		// Token: 0x060007EA RID: 2026 RVA: 0x0002DE08 File Offset: 0x0002C008
		public static float[] RandomFloat(int length, float min, float max)
		{
			float[] array = new float[length];
			for (int i = 0; i < length; i++)
			{
				array[i] = PlaygroundParticlesC.RandomRange(PlaygroundC.random, min, max);
			}
			return array;
		}

		// Token: 0x060007EB RID: 2027 RVA: 0x0002DE40 File Offset: 0x0002C040
		public static void ShuffleArray(float[] arr)
		{
			for (int i = arr.Length - 1; i > 0; i--)
			{
				int num = PlaygroundC.random.Next(0, i);
				float num2 = arr[i];
				arr[i] = arr[num];
				arr[num] = num2;
			}
		}

		// Token: 0x060007EC RID: 2028 RVA: 0x0002DE80 File Offset: 0x0002C080
		public static void ShuffleArray(int[] arr)
		{
			for (int i = arr.Length - 1; i > 0; i--)
			{
				int num = PlaygroundC.random.Next(0, i);
				int num2 = arr[i];
				arr[i] = arr[num];
				arr[num] = num2;
			}
		}

		// Token: 0x060007ED RID: 2029 RVA: 0x0002DEC0 File Offset: 0x0002C0C0
		public static int Largest(int[] compare)
		{
			int num = 0;
			for (int i = 0; i < compare.Length; i++)
			{
				if (compare[i] > num)
				{
					num = i;
				}
			}
			return num;
		}

		// Token: 0x060007EE RID: 2030 RVA: 0x0002DEF0 File Offset: 0x0002C0F0
		public static int CountZeroAlphasInTexture(Texture2D image)
		{
			int num = 0;
			Color32[] pixels = image.GetPixels32();
			for (int i = 0; i < pixels.Length; i++)
			{
				if (pixels[i].a == 0)
				{
					num++;
				}
			}
			return num;
		}

		// Token: 0x060007EF RID: 2031 RVA: 0x0002DF30 File Offset: 0x0002C130
		public static GameObject ResourceInstantiate(string n)
		{
			GameObject gameObject = Resources.Load(n) as GameObject;
			if (!gameObject)
			{
				return null;
			}
			GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject);
			gameObject2.name = n;
			return gameObject2;
		}

		// Token: 0x060007F0 RID: 2032 RVA: 0x0002DF68 File Offset: 0x0002C168
		public static void TimeReset()
		{
			PlaygroundC.globalDeltaTime = 0f;
			PlaygroundC.globalTime = Time.timeSinceLevelLoad;
			PlaygroundC.lastTimeUpdated = PlaygroundC.globalTime;
		}

		// Token: 0x060007F1 RID: 2033 RVA: 0x0002DF88 File Offset: 0x0002C188
		public virtual IEnumerator InitializePlayground()
		{
			if (PlaygroundC.reference != null && PlaygroundC.reference != this)
			{
				yield return null;
				global::Debug.Log("There can only be one instance of the Playground Manager in the scene.");
				foreach (object obj in base.transform)
				{
					Transform child = (Transform)obj;
					child.parent = null;
				}
				UnityEngine.Object.DestroyImmediate(base.gameObject);
				yield break;
			}
			if (PlaygroundC.reference == null)
			{
				PlaygroundC.reference = this;
			}
			PlaygroundC.CheckEvents();
			PlaygroundC.random = new System.Random();
			PlaygroundC.TimeReset();
			for (int i = 0; i < this.particleSystems.Count; i++)
			{
				if (this.particleSystems[i] != null)
				{
					this.particleSystems[i].particleSystemId = i;
				}
				else
				{
					this.particleSystems.RemoveAt(i);
					i--;
				}
			}
			PlaygroundC.particlesQuantity = this.particleSystems.Count;
			this.frameCount = 0;
			this.threadAggregatorRuns = 0;
			this.isReady = true;
			this.isDoneThread = true;
			this.isDoneThreadLocal = true;
			this.isDoneThreadSkinned = true;
			this.isDoneThreadTurbulence = true;
			PlaygroundC.SetMaxThreads(this.maxThreads);
			yield break;
		}

		// Token: 0x060007F2 RID: 2034 RVA: 0x0002DFA4 File Offset: 0x0002C1A4
		public static bool IsReady()
		{
			return PlaygroundC.reference.isReady;
		}

		// Token: 0x060007F3 RID: 2035 RVA: 0x0002DFB0 File Offset: 0x0002C1B0
		public static void SetTime()
		{
			if (!Application.isPlaying || !PlaygroundC.reference.globalTimeScale)
			{
				PlaygroundC.globalTime += (Time.realtimeSinceStartup - PlaygroundC.lastTimeUpdated) * PlaygroundC.globalTimescale;
			}
			else
			{
				PlaygroundC.globalTime += Time.deltaTime * PlaygroundC.globalTimescale;
			}
			PlaygroundC.globalDeltaTime = PlaygroundC.globalTime - PlaygroundC.lastTimeUpdated;
			PlaygroundC.lastTimeUpdated = PlaygroundC.globalTime;
		}

		// Token: 0x060007F4 RID: 2036 RVA: 0x0002E028 File Offset: 0x0002C228
		public static void SetMaxThreads(int threadCount)
		{
			if (!PlaygroundC.HasReference())
			{
				return;
			}
			PlaygroundC.reference.maxThreads = Mathf.Clamp(threadCount, 1, 128);
			PlaygroundC.processorCount = SystemInfo.processorCount;
			PlaygroundC.reference.threads = Mathf.Clamp((PlaygroundC.processorCount <= 1) ? 1 : (PlaygroundC.processorCount - 1), 1, PlaygroundC.reference.maxThreads);
			PlaygroundC.reference._prevMaxThreadCount = PlaygroundC.reference.maxThreads;
			if (PlaygroundC.reference.threadPoolMethod == ThreadPoolMethod.PlaygroundPool && PlaygroundC.playgroundPool != null)
			{
				PlaygroundC.playgroundPool.SetThreadPool(PlaygroundC.reference.maxThreads);
			}
		}

		// Token: 0x060007F5 RID: 2037 RVA: 0x0002E0D4 File Offset: 0x0002C2D4
		private static void CheckEvents()
		{
			PlaygroundC.particleEventBirthInitialized = (PlaygroundC.particleEventBirth != null);
			PlaygroundC.particleEventDeathInitialized = (PlaygroundC.particleEventDeath != null);
			PlaygroundC.particleEventCollisionInitialized = (PlaygroundC.particleEventCollision != null);
			PlaygroundC.particleEventTimeInitialized = (PlaygroundC.particleEventTime != null);
		}

		// Token: 0x060007F6 RID: 2038 RVA: 0x0002E124 File Offset: 0x0002C324
		public virtual void OnEnable()
		{
			PlaygroundC.referenceTransform = base.transform;
			PlaygroundC.referenceGameObject = base.gameObject;
			base.StartCoroutine(this.InitializePlayground());
		}

		// Token: 0x060007F7 RID: 2039 RVA: 0x0002E14C File Offset: 0x0002C34C
		public virtual void Start()
		{
			PlaygroundC.SetTime();
		}

		// Token: 0x060007F8 RID: 2040 RVA: 0x0002E154 File Offset: 0x0002C354
		public virtual void LateUpdate()
		{
			PlaygroundC.activeThreads = 0;
			if (this.activeSystems.Count > 0)
			{
				this.activeSystems.Clear();
			}
			this.frameCount++;
			this.isFirstUnsafeAutomaticFrames = (this.frameCount < PlaygroundC.unsafeAutomaticThreadFrames || this.threadAggregatorRuns < PlaygroundC.unsafeAutomaticThreadFrames);
			if (PlaygroundC.reference != this)
			{
				this.InitializePlayground();
				return;
			}
			PlaygroundC.SetTime();
			PlaygroundC.CheckEvents();
			PlaygroundC.hasReference = (PlaygroundC.reference != null);
			PlaygroundC.hasPlaygroundPool = (PlaygroundC.playgroundPool != null);
			if (this.threadPoolMethod == ThreadPoolMethod.PlaygroundPool && this.maxThreads != this._prevMaxThreadCount)
			{
				PlaygroundC.SetMaxThreads(this.maxThreads);
			}
			for (int i = 0; i < this.manipulators.Count; i++)
			{
				this.manipulators[i].Update();
			}
			if (this.particleSystems.Count == 0)
			{
				return;
			}
			this.hasActiveParticleSystems = false;
			this.hasLocalNoThreads = false;
			this.hasLocalOnePerSystem = false;
			this.hasLocalOneForAll = false;
			this.hasActiveSkinnedMeshes = false;
			this.hasActiveTurbulence = false;
			if (this.previousThreadMethod != this.threadMethod)
			{
				this.isDoneThread = true;
				this.previousThreadMethod = this.threadMethod;
			}
			if (this.threadMethod != ThreadMethod.OneForAll)
			{
				this.isDoneThread = true;
			}
			if (this.previousSkinnedMeshThreadMethod != this.skinnedMeshThreadMethod)
			{
				this.isDoneThreadSkinned = true;
				this.previousSkinnedMeshThreadMethod = this.skinnedMeshThreadMethod;
			}
			if (this.previousTurbulenceThreadMethod != this.turbulenceThreadMethod)
			{
				this.isDoneThreadTurbulence = true;
				this.previousTurbulenceThreadMethod = this.turbulenceThreadMethod;
			}
			Camera main = Camera.main;
			bool flag = false;
			bool flag2 = false;
			int count = this.particleSystems.Count;
			for (int j = 0; j < this.particleSystems.Count; j++)
			{
				if (this.particleSystems[j] == null)
				{
					this.particleSystems.RemoveAt(j);
					j--;
					if (j < 0)
					{
						j = 0;
					}
				}
				else if (!this.particleSystems[j].isSnapshot && this.particleSystems[j].shurikenParticleSystem != null && this.particleSystems[j].particleSystemGameObject.activeInHierarchy && this.particleSystems[j].Initialized() && !this.particleSystems[j].IsSettingParticleCount() && !this.particleSystems[j].IsSettingLifetime() && !this.particleSystems[j].IsYieldRefreshing() && !this.particleSystems[j].InTransition() && !this.particleSystems[j].IsLoading() && !this.particleSystems[j].IsPrewarming() && !this.particleSystems[j].IsSettingParticleTime() && !this.particleSystems[j].inPlayback)
				{
					if (Time.frameCount % this.particleSystems[j].updateRate != 0)
					{
						for (int k = 0; k < this.particleSystems[j].particleCount; k++)
						{
							this.particleSystems[j].particleCache[k].lifetime = this.particleSystems[j].playgroundCache.death[k] - this.particleSystems[j].playgroundCache.birth[k] - this.particleSystems[j].playgroundCache.lifetimeSubtraction[k];
						}
						this.particleSystems[j].isReadyForThreadedCalculations = false;
					}
					else
					{
						if (count > this.particleSystems.Count)
						{
							if (j <= 0)
							{
								this.hasActiveParticleSystems = false;
								return;
							}
							j--;
							count = this.particleSystems.Count;
						}
						else if (count < this.particleSystems.Count)
						{
							count = this.particleSystems.Count;
						}
						if (this.particleSystems.Count == 0 || j >= this.particleSystems.Count)
						{
							this.hasActiveParticleSystems = false;
							return;
						}
						if (!flag && this.particleSystems[j].pauseCalculationWhenInvisible && main != null && main.enabled)
						{
							PlaygroundC.frustumPlanes = GeometryUtility.CalculateFrustumPlanes(main);
							flag = true;
						}
						if ((!this.particleSystems[j].onlySourcePositioning && !this.particleSystems[j].onlyLifetimePositioning) || this.particleSystems[j].UpdateSystem())
						{
							if (this.particleSystems.Count > 0 && j < this.particleSystems.Count)
							{
								this.particleSystems[j].isReadyForThreadedCalculations = this.particleSystems[j].PrepareThreadedCalculations();
								if (this.particleSystems[j].IsAlive())
								{
									this.hasActiveParticleSystems = true;
									if (this.particleSystems[j].onlySourcePositioning || this.particleSystems[j].onlyLifetimePositioning)
									{
										flag2 = true;
									}
									if (this.threadMethod == ThreadMethod.Automatic)
									{
										this.activeSystems.Add(j);
									}
									if (!this.particleSystems[j].forceSkinnedMeshUpdateOnMainThread && this.particleSystems[j].IsSkinnedWorldObjectReady() && this.particleSystems[j].calculate)
									{
										this.hasActiveSkinnedMeshes = true;
									}
									if (this.particleSystems[j].HasTurbulence() && this.particleSystems[j].calculate)
									{
										this.hasActiveTurbulence = true;
									}
									switch (this.particleSystems[j].threadMethod)
									{
									case ThreadMethodLocal.NoThreads:
										this.hasLocalNoThreads = true;
										break;
									case ThreadMethodLocal.OnePerSystem:
										this.hasLocalOnePerSystem = true;
										break;
									case ThreadMethodLocal.OneForAll:
										this.hasLocalOneForAll = true;
										break;
									}
								}
								else
								{
									this.particleSystems[j].isReadyForThreadedCalculations = false;
								}
							}
							else if (this.particleSystems.Count > 0 && j < this.particleSystems.Count && this.particleSystems[j] != null)
							{
								this.particleSystems[j].isReadyForThreadedCalculations = false;
							}
						}
					}
				}
				else if (this.particleSystems[j] != null)
				{
					this.particleSystems[j].isReadyForThreadedCalculations = false;
					if (this.particleSystems[j].IsPrewarming() && this.particleSystems[j].HasTurbulence())
					{
						this.hasActiveTurbulence = true;
						this.hasActiveParticleSystems = true;
					}
				}
			}
			if (this.hasActiveParticleSystems)
			{
				this.ThreadAggregator();
				if (flag2)
				{
					for (int l = 0; l < this.particleSystems.Count; l++)
					{
						if (this.particleSystems[l] != null && (this.particleSystems[l].onlySourcePositioning || this.particleSystems[l].onlyLifetimePositioning) && this.particleSystems[l].isReadyForThreadedCalculations && !this.particleSystems[l].InTransition() && !this.particleSystems[l].IsLoading() && this.particleSystems[l].IsReady())
						{
							this.particleSystems[l].UpdateShuriken();
						}
					}
				}
			}
		}

		// Token: 0x060007F9 RID: 2041 RVA: 0x0002E9BC File Offset: 0x0002CBBC
		public virtual void Update()
		{
			int count = this.particleSystems.Count;
			for (int i = 0; i < this.particleSystems.Count; i++)
			{
				if (count > this.particleSystems.Count)
				{
					if (i <= 0)
					{
						this.hasActiveParticleSystems = false;
						return;
					}
					i--;
					count = this.particleSystems.Count;
				}
				else if (count < this.particleSystems.Count)
				{
					count = this.particleSystems.Count;
				}
				if (this.particleSystems.Count == 0 || i >= this.particleSystems.Count)
				{
					this.hasActiveParticleSystems = false;
					return;
				}
				if (this.particleSystems[i] != null && !this.particleSystems[i].onlySourcePositioning && !this.particleSystems[i].onlyLifetimePositioning && this.particleSystems[i].UpdateSystem() && this.particleSystems[i].isReadyForThreadedCalculations && !this.particleSystems[i].InTransition() && !this.particleSystems[i].IsLoading() && !this.particleSystems[i].IsSettingParticleTime() && this.particleSystems[i].IsReady() && !this.particleSystems[i].inPlayback)
				{
					this.particleSystems[i].UpdateShuriken();
				}
			}
		}

		// Token: 0x060007FA RID: 2042 RVA: 0x0002EB60 File Offset: 0x0002CD60
		public static int ActiveThreads()
		{
			return PlaygroundC.activeThreads;
		}

		// Token: 0x060007FB RID: 2043 RVA: 0x0002EB68 File Offset: 0x0002CD68
		public static int ProcessorCount()
		{
			return PlaygroundC.processorCount;
		}

		// Token: 0x060007FC RID: 2044 RVA: 0x0002EB70 File Offset: 0x0002CD70
		public virtual void ThreadAggregator()
		{
			if (this.hasActiveSkinnedMeshes)
			{
				switch (this.skinnedMeshThreadMethod)
				{
				case ThreadMethodComponent.OnePerSystem:
					for (int i = 0; i < this.particleSystems.Count; i++)
					{
						if (!this.particleSystems[i].forceSkinnedMeshUpdateOnMainThread && this.particleSystems[i].IsSkinnedWorldObjectReady())
						{
							this.particleSystems[i].skinnedWorldObject.UpdateOnNewThread();
						}
					}
					break;
				case ThreadMethodComponent.OneForAll:
					if (this.isDoneThreadSkinned)
					{
						this.isDoneThreadSkinned = false;
						PlaygroundC.RunAsync(delegate()
						{
							if (this.isDoneThreadSkinned)
							{
								return;
							}
							for (int num7 = 0; num7 < this.particleSystems.Count; num7++)
							{
								if (!this.particleSystems[num7].forceSkinnedMeshUpdateOnMainThread && this.particleSystems[num7].IsSkinnedWorldObjectReady())
								{
									this.particleSystems[num7].skinnedWorldObject.Update();
								}
							}
							this.isDoneThreadSkinned = true;
						});
					}
					break;
				}
			}
			if (this.hasActiveTurbulence && this.turbulenceThreadMethod == ThreadMethodComponent.OneForAll && this.isDoneThreadTurbulence)
			{
				this.isDoneThreadTurbulence = false;
				PlaygroundC.RunAsync(delegate()
				{
					if (this.isDoneThreadTurbulence)
					{
						return;
					}
					for (int num7 = 0; num7 < this.particleSystems.Count; num7++)
					{
						if (this.particleSystems[num7].HasTurbulence())
						{
							for (int num8 = 0; num8 < this.particleSystems[num7].particleCount; num8++)
							{
								if (!this.particleSystems[num7].playgroundCache.noForce[num8])
								{
									PlaygroundParticlesC.Turbulence(this.particleSystems[num7], this.particleSystems[num7].GetSimplex(), num8, this.particleSystems[num7].GetDeltaTime(), this.particleSystems[num7].turbulenceType, this.particleSystems[num7].turbulenceTimeScale, this.particleSystems[num7].turbulenceScale / this.particleSystems[num7].velocityScale, this.particleSystems[num7].turbulenceStrength, this.particleSystems[num7].turbulenceApplyLifetimeStrength, this.particleSystems[num7].turbulenceLifetimeStrength);
								}
							}
						}
						this.isDoneThreadTurbulence = true;
					}
				});
			}
			if (this.hasLocalNoThreads)
			{
				for (int j = 0; j < this.particleSystems.Count; j++)
				{
					if (this.particleSystems[j].isReadyForThreadedCalculations && this.particleSystems[j].threadMethod == ThreadMethodLocal.NoThreads)
					{
						PlaygroundParticlesC.ThreadedCalculations(this.particleSystems[j]);
					}
				}
			}
			if (this.hasLocalOnePerSystem)
			{
				for (int k = 0; k < this.particleSystems.Count; k++)
				{
					if (this.particleSystems[k].threadMethod == ThreadMethodLocal.OnePerSystem)
					{
						PlaygroundParticlesC.NewCalculatedThread(this.particleSystems[k]);
					}
				}
			}
			if ((this.hasLocalOneForAll || (this.isFirstUnsafeAutomaticFrames && this.threadMethod == ThreadMethod.Automatic)) && this.isDoneThreadLocal)
			{
				this.isDoneThreadLocal = false;
				PlaygroundC.RunAsync(delegate()
				{
					if (this.isDoneThreadLocal)
					{
						return;
					}
					object obj = this.lockerLocal;
					lock (obj)
					{
						for (int num7 = 0; num7 < this.particleSystems.Count; num7++)
						{
							if (this.particleSystems[num7].isReadyForThreadedCalculations && (this.particleSystems[num7].threadMethod == ThreadMethodLocal.OneForAll || this.isFirstUnsafeAutomaticFrames))
							{
								this.particleSystems[num7].IsDoneThread = true;
								PlaygroundParticlesC.ThreadedCalculations(this.particleSystems[num7]);
							}
						}
						this.isDoneThreadLocal = true;
					}
				});
			}
			switch (this.threadMethod)
			{
			case ThreadMethod.NoThreads:
				for (int l = 0; l < this.particleSystems.Count; l++)
				{
					if (this.particleSystems[l].isReadyForThreadedCalculations && this.particleSystems[l].threadMethod == ThreadMethodLocal.Inherit)
					{
						PlaygroundParticlesC.ThreadedCalculations(this.particleSystems[l]);
					}
				}
				break;
			case ThreadMethod.OnePerSystem:
				for (int m = 0; m < this.particleSystems.Count; m++)
				{
					if (this.particleSystems[m].threadMethod == ThreadMethodLocal.Inherit && this.particleSystems[m].isReadyForThreadedCalculations)
					{
						PlaygroundParticlesC.NewCalculatedThread(this.particleSystems[m]);
					}
				}
				break;
			case ThreadMethod.OneForAll:
				if (this.isDoneThread)
				{
					this.isDoneThread = false;
					PlaygroundC.RunAsync(delegate()
					{
						if (this.isDoneThread)
						{
							return;
						}
						object obj = PlaygroundC.locker;
						lock (obj)
						{
							for (int num7 = 0; num7 < this.particleSystems.Count; num7++)
							{
								if (this.particleSystems[num7].isReadyForThreadedCalculations && this.particleSystems[num7].threadMethod == ThreadMethodLocal.Inherit)
								{
									PlaygroundParticlesC.ThreadedCalculations(this.particleSystems[num7]);
								}
							}
							this.isDoneThread = true;
						}
					});
				}
				break;
			case ThreadMethod.Automatic:
				if (!this.isFirstUnsafeAutomaticFrames)
				{
					this.maxThreads = Mathf.Clamp(this.maxThreads, 1, 128);
					this.threads = Mathf.Clamp((PlaygroundC.processorCount <= 1) ? 1 : (PlaygroundC.processorCount - 1), 1, this.maxThreads);
					if (this.activeSystems.Count <= this.threads)
					{
						for (int n = 0; n < this.particleSystems.Count; n++)
						{
							if (this.particleSystems[n].isReadyForThreadedCalculations && this.particleSystems[n].threadMethod == ThreadMethodLocal.Inherit)
							{
								PlaygroundParticlesC.NewCalculatedThread(this.particleSystems[n]);
							}
						}
					}
					else
					{
						int num = 0;
						float num2 = (float)this.activeSystems.Count * 1f / (float)this.threads * 1f;
						float num3 = 0f;
						int num4 = 0;
						for (int num5 = 0; num5 < this.threads; num5++)
						{
							num3 += num2;
							PlaygroundParticlesC[] array = new PlaygroundParticlesC[Mathf.RoundToInt(num3 - (float)num4)];
							num4 += array.Length;
							for (int num6 = 0; num6 < array.Length; num6++)
							{
								if (num < this.activeSystems.Count)
								{
									array[num6] = this.particleSystems[this.activeSystems[num]];
								}
								num++;
							}
							PlaygroundParticlesC.NewCalculatedThread(array);
						}
					}
				}
				break;
			}
			if (this.threadMethod != ThreadMethod.NoThreads && PlaygroundC.activeThreads == 0)
			{
				PlaygroundC.activeThreads = 1;
			}
			this.threadAggregatorRuns++;
		}

		// Token: 0x060007FD RID: 2045 RVA: 0x0002F030 File Offset: 0x0002D230
		public static void RunAsync(Action a, ThreadPoolMethod threadPoolMethod)
		{
			if (threadPoolMethod == ThreadPoolMethod.ThreadPool)
			{
				object obj = PlaygroundC.locker;
				lock (obj)
				{
					ThreadPool.QueueUserWorkItem(new WaitCallback(PlaygroundC.RunAction), a);
				}
			}
			else
			{
				PlaygroundC.RunAsyncPlaygroundPool(a);
			}
		}

		// Token: 0x060007FE RID: 2046 RVA: 0x0002F08C File Offset: 0x0002D28C
		public static void RunAsync(Action a)
		{
			if (!PlaygroundC.HasReference() || PlaygroundC.reference.threadPoolMethod == ThreadPoolMethod.ThreadPool)
			{
				object obj = PlaygroundC.locker;
				lock (obj)
				{
					ThreadPool.QueueUserWorkItem(new WaitCallback(PlaygroundC.RunAction), a);
				}
			}
			else
			{
				PlaygroundC.RunAsyncPlaygroundPool(a);
			}
		}

		// Token: 0x060007FF RID: 2047 RVA: 0x0002F0F8 File Offset: 0x0002D2F8
		public static void RunAsyncPlaygroundPool(Action a)
		{
			if (!PlaygroundC.HasPlaygroundPool())
			{
				PlaygroundC.playgroundPool = new PlaygroundQueue<Action>((!PlaygroundC.HasReference()) ? (SystemInfo.processorCount * 2) : PlaygroundC.reference.maxThreads, new Action<Action>(PlaygroundC.RunAction));
				PlaygroundC.hasPlaygroundPool = true;
			}
			PlaygroundC.playgroundPool.EnqueueTask(a);
		}

		// Token: 0x06000800 RID: 2048 RVA: 0x0002F158 File Offset: 0x0002D358
		private static void RunAction(object a)
		{
			try
			{
				((Action)a)();
			}
			catch
			{
			}
		}

		// Token: 0x040007B1 RID: 1969
		public static int meshQuantity;

		// Token: 0x040007B2 RID: 1970
		public static int particlesQuantity;

		// Token: 0x040007B3 RID: 1971
		public static float version = 3.03f;

		// Token: 0x040007B4 RID: 1972
		public static string specialVersion = " ";

		// Token: 0x040007B5 RID: 1973
		public static float globalTime;

		// Token: 0x040007B6 RID: 1974
		public static float lastTimeUpdated;

		// Token: 0x040007B7 RID: 1975
		public static float globalDeltaTime;

		// Token: 0x040007B8 RID: 1976
		public static float globalTimescale = 1f;

		// Token: 0x040007B9 RID: 1977
		public static Vector3 initialTargetPosition = new Vector3(0f, -999.99f, 0f);

		// Token: 0x040007BA RID: 1978
		public static int skinnedUpdateRate = 1;

		// Token: 0x040007BB RID: 1979
		public static bool triggerSceneRepaint = true;

		// Token: 0x040007BC RID: 1980
		public static float collisionSleepVelocity = 0.01f;

		// Token: 0x040007BD RID: 1981
		public static int unsafeAutomaticThreadFrames = 20;

		// Token: 0x040007BE RID: 1982
		public static Plane[] frustumPlanes;

		// Token: 0x040007BF RID: 1983
		protected static bool particleEventBirthInitialized = false;

		// Token: 0x040007C0 RID: 1984
		protected static bool particleEventDeathInitialized = false;

		// Token: 0x040007C1 RID: 1985
		protected static bool particleEventCollisionInitialized = false;

		// Token: 0x040007C2 RID: 1986
		protected static bool particleEventTimeInitialized = false;

		// Token: 0x040007C3 RID: 1987
		public static PlaygroundC reference;

		// Token: 0x040007C4 RID: 1988
		public static Transform referenceTransform;

		// Token: 0x040007C5 RID: 1989
		public static GameObject referenceGameObject;

		// Token: 0x040007C6 RID: 1990
		[SerializeField]
		public List<PlaygroundParticlesC> particleSystems = new List<PlaygroundParticlesC>();

		// Token: 0x040007C7 RID: 1991
		[SerializeField]
		public List<ManipulatorObjectC> manipulators = new List<ManipulatorObjectC>();

		// Token: 0x040007C8 RID: 1992
		[HideInInspector]
		public int paintMaxPositions = 10000;

		// Token: 0x040007C9 RID: 1993
		[HideInInspector]
		public bool calculate = true;

		// Token: 0x040007CA RID: 1994
		[HideInInspector]
		public PIXELMODEC pixelFilterMode = PIXELMODEC.Pixel32;

		// Token: 0x040007CB RID: 1995
		[HideInInspector]
		public bool autoGroup = true;

		// Token: 0x040007CC RID: 1996
		[HideInInspector]
		public bool buildZeroAlphaPixels;

		// Token: 0x040007CD RID: 1997
		[HideInInspector]
		public bool drawGizmos = true;

		// Token: 0x040007CE RID: 1998
		[HideInInspector]
		public bool drawSourcePositions;

		// Token: 0x040007CF RID: 1999
		[HideInInspector]
		public bool showShuriken;

		// Token: 0x040007D0 RID: 2000
		[HideInInspector]
		public bool paintToolbox = true;

		// Token: 0x040007D1 RID: 2001
		[HideInInspector]
		public float collisionPlaneScale = 0.1f;

		// Token: 0x040007D2 RID: 2002
		[HideInInspector]
		public bool showSnapshotsInHierarchy;

		// Token: 0x040007D3 RID: 2003
		[HideInInspector]
		public bool drawWireframe;

		// Token: 0x040007D4 RID: 2004
		[HideInInspector]
		public bool drawSplinePreview = true;

		// Token: 0x040007D5 RID: 2005
		[HideInInspector]
		public bool globalTimeScale = true;

		// Token: 0x040007D6 RID: 2006
		[HideInInspector]
		public ThreadPoolMethod threadPoolMethod = ThreadPoolMethod.PlaygroundPool;

		// Token: 0x040007D7 RID: 2007
		[HideInInspector]
		public ThreadMethod threadMethod = ThreadMethod.Automatic;

		// Token: 0x040007D8 RID: 2008
		[HideInInspector]
		public ThreadMethodComponent skinnedMeshThreadMethod;

		// Token: 0x040007D9 RID: 2009
		[HideInInspector]
		public ThreadMethodComponent turbulenceThreadMethod;

		// Token: 0x040007DA RID: 2010
		[HideInInspector]
		public int maxThreads = 8;

		// Token: 0x040007DB RID: 2011
		public static PlaygroundQueue<Action> playgroundPool;

		// Token: 0x040007DC RID: 2012
		protected bool isDoneThread = true;

		// Token: 0x040007DD RID: 2013
		protected bool isDoneThreadLocal = true;

		// Token: 0x040007DE RID: 2014
		protected bool isDoneThreadSkinned = true;

		// Token: 0x040007DF RID: 2015
		protected bool isDoneThreadTurbulence = true;

		// Token: 0x040007E0 RID: 2016
		protected int threads;

		// Token: 0x040007E1 RID: 2017
		protected int _prevMaxThreadCount;

		// Token: 0x040007E2 RID: 2018
		protected static int processorCount;

		// Token: 0x040007E3 RID: 2019
		protected static int activeThreads = 0;

		// Token: 0x040007E4 RID: 2020
		protected static bool hasReference = false;

		// Token: 0x040007E5 RID: 2021
		protected static bool hasPlaygroundPool = false;

		// Token: 0x040007E6 RID: 2022
		protected static System.Random random = new System.Random();

		// Token: 0x040007E7 RID: 2023
		protected static object locker = new object();

		// Token: 0x040007E8 RID: 2024
		protected object lockerLocal = new object();

		// Token: 0x040007E9 RID: 2025
		protected int frameCount;

		// Token: 0x040007EA RID: 2026
		protected bool isReady;

		// Token: 0x040007EB RID: 2027
		protected bool hasActiveParticleSystems;

		// Token: 0x040007EC RID: 2028
		protected bool hasLocalNoThreads;

		// Token: 0x040007ED RID: 2029
		protected bool hasLocalOnePerSystem;

		// Token: 0x040007EE RID: 2030
		protected bool hasLocalOneForAll;

		// Token: 0x040007EF RID: 2031
		protected bool hasActiveSkinnedMeshes;

		// Token: 0x040007F0 RID: 2032
		protected bool hasActiveTurbulence;

		// Token: 0x040007F1 RID: 2033
		protected bool isFirstUnsafeAutomaticFrames = true;

		// Token: 0x040007F2 RID: 2034
		protected int threadAggregatorRuns;

		// Token: 0x040007F3 RID: 2035
		protected List<int> activeSystems = new List<int>();

		// Token: 0x040007F4 RID: 2036
		protected ThreadMethod previousThreadMethod;

		// Token: 0x040007F5 RID: 2037
		protected ThreadMethodComponent previousSkinnedMeshThreadMethod;

		// Token: 0x040007F6 RID: 2038
		protected ThreadMethodComponent previousTurbulenceThreadMethod;
	}
}
